package com.zhigh.project.security.test.web;

import com.zhigh.project.security.jwt.authentication.InMemorySecretHolder;
import com.zhigh.project.security.jwt.authentication.JWT;
import com.zhigh.project.security.jwt.authentication.JWTAuthenticationProvider;
import com.zhigh.project.security.jwt.authentication.SecretHolder;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.event.LoggerListener;

@Configuration
public class JWTSecurityConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public SecretHolder<JWT> jwtSecretHolder() {
        return new InMemorySecretHolder();
    }

    @Bean
    public JWTAuthenticationProvider jwtAuthenticationProvider() {
        return new JWTAuthenticationProvider(jwtSecretHolder());
    }

    @Bean
    public LoggerListener loggerListener() {
        return new LoggerListener();
    }

}
